package com.example.loggingservice.mapper;

import com.example.loggingservice.entity.OperationLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OperationLogMapper {

    @Insert("INSERT INTO operation_logs(user_id, action, ip, detail) " +
            "VALUES(#{userId}, #{action}, #{ip}, #{detail})")
    @Options(useGeneratedKeys = true, keyProperty = "logId")
    void save(OperationLog log);

    @Select("SELECT log_id, user_id, action, ip, detail FROM operation_logs ORDER BY log_id DESC")
    List<OperationLog> findAll();
} 